local items = {
	settingsfile = "Fdk.json",
	callback = GUICallback,
	{ type = "separator" },
	{ type = "title", text = "冰DK |c0000CED1PvE" },
	{ type = "separator" },
	{ type = "title", text = "|cffFFFF00输出循环" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49909))..":26:26\124t  冰冷触摸", tooltip = "冰冷触摸", enabled = true, key = "IcyTouch" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49921))..":26:26\124t  暗影打击", tooltip = "暗影打击", enabled = true, key = "PlagueStrike" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(50842))..":26:26\124t  传染", tooltip = "传染", enabled = true, key = "Pestilence" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51425))..":26:26\124t  湮没", tooltip = "湮没", enabled = true, key = "Obliterate" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49930))..":26:26\124t  鲜血打击", tooltip = "鲜血打击", enabled = true, key = "BloodStrike" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(55268))..":26:26\124t  冰霜打击", tooltip = "冰霜打击", enabled = true, key = "FrostStrike" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51411))..":26:26\124t  凛风冲击 怪物数量 >", tooltip = "数量", enabled = true, value = 2, key = "HowlingBlast" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49938))..":26:26\124t 使用 枯萎凋零 怪物数量 >", tooltip = "数量", enabled = true, value = 2, key = "DeathandDecay" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49941))..":26:26\124t 使用 血液沸腾 怪物数量 >", tooltip = "数量", enabled = true, value = 4, key = "BloodBoil" },
	{ type = "separator" },
    { type = "page", number = 1, text = "|cffFFFF00保命功能|r" },
	{ type = "separator" },	
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(48792))..":26:26\124t  冰封之韧", tooltip = "冰封之韧", enabled = true, value = 50, key = "IceboundFortitude" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(48743))..":26:26\124t  天灾契约", tooltip = "天灾契约", enabled = false,value = 60, key = "DeathPact" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(48707))..":26:26\124t  反魔法护罩", tooltip = "反魔法护罩", enabled = true,  key = "AntiMagicShell" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(49998))..":26:26\124t  灵界打击", tooltip = "灵界打击", enabled = false, value = 50, key = "DeathStrike" },
	{ type = "entry", text = "\124T"..GetItemIcon(36894)..":26:26\124t  治疗石 HP% <", tooltip = "治疗石", enabled = true, value = 50, key = "FelHealthstone" },
	{ type = "separator" },
	{ type = "page", number = 2, text = "|cFF00FF00辅助功能|r" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(48266))..":26:26\124t  鲜血灵气", tooltip = "鲜血灵气", enabled = true, key = "BloodPresence" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(6603))..":26:26\124t  自动目标", tooltip = "自动目标", enabled = true, key = "AutoAttack" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51306))..":26:26\124t  手套加速", tooltip = "手套加速", enabled = true, key = "Engineeringgloves" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(20572))..":26:26\124t  血性狂怒", tooltip = "血性狂怒", enabled = true, key = "BloodFury" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51271))..":26:26\124t  铜墙铁壁", tooltip = "铜墙铁壁", enabled = true, key = "UnbreakableArmor" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47568))..":26:26\124t  符文武器增效", tooltip = "符文武器增效", enabled = true, key = "EmpowerRuneWeapon" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(57623))..":26:26\124t  寒冬号角", tooltip = "寒冬号角", enabled = true, key = "HornofWinter" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(46584))..":26:26\124t  亡者复生", tooltip = "亡者复生", enabled = true, key = "RaiseDead" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(45529))..":26:26\124t  活力分流", tooltip = "活力分流", enabled = true, key = "BloodTap" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(3714))..":26:26\124t  冰霜之路", tooltip = "冰霜之路", enabled = false, key = "PathofFrost" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51306))..":26:26\124t  调试", tooltip = "显示调试信息", enabled = false, key = "debug" },
	{ type = "separator" },
	{ type = "page", number = 3, text = "|cFF00FF00控制功能|r" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47476))..":26:26\124t  绞袭", tooltip = "绞袭打断", enabled = true, key = "Strangulate" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47528))..":26:26\124t  心灵冰冻", tooltip = "心灵冰冻打断", enabled = true, key = "MindFreeze" }
};
local function GetSetting(name)
    for k, v in ipairs(items) do
        if v.type == "entry"
         and v.key ~= nil
         and v.key == name then
            return v.value, v.enabled
        end
    end
end;

local incombat = false
local playerguid = UnitGUID("player")
local RuneStrikeAvalible = false
local diaolingtm = 0
local chuanrantm = 0

local function CombatEventCatcher(event, ...)
	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
		local _, eventType, _, _, _, destGUID = ...
		if destGUID == playerguid and eventType == "SWING_MISSED" then
			local misstype = select(9, ...)
			if misstype == "BLOCK" or misstype == "DODGE"  then
				RuneStrikeAvalible = true
			end
		end
	end
	if event == "UNIT_SPELLCAST_SUCCEEDED"  then
	    local d,e,a,b,f,c = ...
		if d =="player"
		then
		   if e=="枯萎凋零"   
		   then
		      diaolingtm = GetTime()
		   end
		   if e =="传染"
		   then
		      chuanrantm = GetTime()
		   end
		end
	end
	if event == "PLAYER_REGEN_DISABLED" then
		incombat = true
	elseif event == "PLAYER_REGEN_ENABLED" then
		incombat = false
	end
end;

local function OnLoad()
    ni.combatlog.registerhandler("Fdk", CombatEventCatcher)
	ni.GUI.AddFrame("Fdk", items);
end;

local function OnUnLoad()  
    ni.combatlog.unregisterhandler("Fdk")
	ni.GUI.DestroyFrame("Fdk");
end;

local spells = {
		AutoAttack = { id = 6603, name = GetSpellInfo(6603)},    --攻击
		BloodFury = { id = 20572, name = GetSpellInfo(20572)},    --血性狂怒
		--Blood icon = select(2, GetSpellTabInfo(2))
		BloodBoil = { id = 49941, name = GetSpellInfo(49941)},                 --血液沸腾
		BloodPresence = { id = 48266, name = GetSpellInfo(48266)},             --鲜血灵气
		BloodStrike = { id = 49930, name = GetSpellInfo(49930)},               --鲜血打击
		DeathStrike = { id = 49998, name = GetSpellInfo(49998)},               --灵界打击
		HeartStrike = { id = 55050, name = GetSpellInfo(55050)},               --心脏打击
		Pestilence = { id = 50842, name = GetSpellInfo(50842)},                --传染  
		RuneTap = { id = 48982, name = GetSpellInfo(48982)},                   --符文分流
		Strangulate = { id = 47476, name = GetSpellInfo(47476)},               --绞袭            
		VampiricBlood = { id = 55233, name = GetSpellInfo(55233)},             --吸血鬼之血            
		BloodTap = { id = 45529, name = GetSpellInfo(45529)},                 --活力分流 
		DarkCommand = { id = 56222, name = GetSpellInfo(56222)},              --黑暗命令
		DeathPact = { id = 48743, name = GetSpellInfo(48743)},                --天灾契约
		--Frost icon = select(2, GetSpellTabInfo(3))
		ChainsofIce = { id = 45524, name = GetSpellInfo(45524)},              --寒冰锁链
		FrostFever = { id = 48263, name = GetSpellInfo(48263)},               --冰霜灵气
		FrostStrike = { id = 55268, name = GetSpellInfo(55268)},              --冰霜打击
		FrostPresence = { id = 55095, name = GetSpellInfo(55095)},            --冰霜疫病
		IceboundFortitude = { id = 48792, name = GetSpellInfo(48792)},        --冰封之韧
		IcyTouch = { id = 49909, name = GetSpellInfo(49909)},                 --冰冷触摸                 
		HowlingBlast = { id = 51411, name = GetSpellInfo(51411)},             --凛风冲击
		MindFreeze = { id = 47528, name = GetSpellInfo(47528)},               --心灵冰冻
		Obliterate = { id = 51425, name = GetSpellInfo(51425)},               --湮没
		PathofFrost = { id = 3714, name = GetSpellInfo(3714)},                 --冰霜之路
		RunicFocus = { id = 61455, name = GetSpellInfo(61455)},               --符文专注
		HornofWinter = { id = 57623, name = GetSpellInfo(57623)},             --寒冬号角
		RuneStrike = { id = 56815, name = GetSpellInfo(56815)},               --符文打击
		EmpowerRuneWeapon = { id = 47568, name = GetSpellInfo(47568)},        --符文武器增效
		UnbreakableArmor = { id = 51271, name = GetSpellInfo(51271)},        --铜墙铁壁
		--Unholy icon = select(2, GetSpellTabInfo(4))
		BloodPlague = { id = 55078, name = GetSpellInfo(55078)},              --血之疫病
		DeathandDecay = { id = 49938, name = GetSpellInfo(49938)},            --枯萎凋零
		DeathCoil = { id = 49895, name = GetSpellInfo(49895)},                --凋零缠绕
		DeathGate = { id = 50977, name = GetSpellInfo(50977)},                --黑锋之门
		DeathGrip = { id = 49576, name = GetSpellInfo(49576)},                --死亡之握
		PlagueStrike = { id = 49921, name = GetSpellInfo(49921)},             --暗影打击
		RaiseDead = { id = 46584, name = GetSpellInfo(46584)},                --亡者复生
		AntiMagicShell = { id = 48707, name = GetSpellInfo(48707)},           --反魔法护罩
		UnholyPresence = { id = 48265, name = GetSpellInfo(48265)},           --邪恶灵气
		RaiseAlly = { id = 61999, name = GetSpellInfo(61999)},                --复活盟友
		ArmyoftheDead = { id = 42650, name = GetSpellInfo(42650)}             --亡者大军
};

local Cache = {
		enemiesn = ni.player.enemiesinrange(30),
};

local queue = {
	"debug",
	"Cache",
	"Pause",
	"AutoAttack",
	"Strangulate",     --绞袭
	"MindFreeze",     --心灵冰冻
	"AntiMagicShell",   --反魔法护罩
	"IceboundFortitude",     --冰封之韧
	"BloodPresence",   --鲜血灵气
	"DeathPact",  --天灾契约
	"DeathStrike",  --灵界打击
	"UnbreakableArmor",  --铜墙铁壁
	"BloodFury", 
	"BloodTap",  --活力分流
	"EmpowerRuneWeapon",  --符文武器增效
	"RaiseDead", --亡者复生
	"Engineeringgloves",  --手套加速
	"Pestilence",   --传染
	"IcyTouch",  --冰冷触摸
	"PlagueStrike",  --暗影打击
	"DeathandDecay",   --枯萎凋零	
	"HowlingBlast",   --凛风冲击
	"BloodBoil",  --血液沸腾
	"FrostStrike",  --冰霜打击
	"Obliterate",  --湮没
	"HowlingBlastTC",
	"HornofWinter",  --寒冬号角
	"BloodStrike",  --鲜血打击
	"HornofWinterBF"  --寒冬号角
};

local function Tank(t)
	if ni.unit.aura(t, 9634)
    or ni.unit.aura(t, 48263)
	or ni.unit.aura(t, 71)
    or ni.unit.aura(t, 25780) then
		return true
	end
	return false
end;

local function Usableplayer(id)
   if ni.spell.available(id) and UnitAffectingCombat("player") then
		return true
	end
	return false
end;

local function ValidUsable(id, tar)
	if ni.spell.available(id) and ni.spell.valid(tar, id, true, true) and UnitAffectingCombat(tar) then
		return true
	end
	return false
end;

local function NValidUsable(id, tar)
	if ni.spell.available(id) and ni.spell.valid(tar, id, false, true, true) then
		return true
	end
	return false
end;

local function Ddmb(tar)
   if ni.unit.iscasting(tar) or ni.unit.ischanneling(tar) then
        return true 
   end
   return false
 end;

 local function sbpd(tar)  --最短病判断
     local bb = ni.unit.debuffremaining(tar, 55095,"player") or 0
	 local xb = ni.unit.debuffremaining(tar, 55078,"player") or 0
     if bb  > xb then b = xb
	 else b = bb  
	 return b
	 end
 end;

 function swxxpd()  --鲜血符文与死亡符文最快冷却
    local BloodStart1, a, b = GetRuneCooldown(1)
    local BloodStart2, c, d = GetRuneCooldown(2)
	local stme = GetTime()
	local stm1 = stme -BloodStart1
	local stm2 = stme -BloodStart2
	local fwzb
    if a-stm1 <= 0 and c-stm2 <= 0 then  fwzb = 0
	elseif a-stm1 <= 0 and c-stm2 > 0 then fwzb = c-stm2
	elseif c-stm1 <= 0 and a-stm1 > 0 then fwzb = a-stm1
	elseif a-stm1 > c-stm2 then  fwzb = c-stm2
	else fwzb = a-stm1
	end
	return fwzb
end;

local function fwtj(number)
    local xxs = select(2, ni.rune.bloodrunecd())                    --鲜血符文
	local sws = select(2, ni.rune.deathrunecd())                    --死亡符文
	local bss = select(2, ni.rune.frostrunecd())                    --冰霜符文
	local xes = select(2, ni.rune.unholyrunecd())                   --邪恶符文	

	if number  == 7 then
	   return (xes + sws > 0)
	end

	if number  == 6 then
	   return (bss + sws > 0 )
	end

	if number  == 5 then
	     return   (xxs + sws)
	end

    if number  == 4 then
	   return (xxs + sws > 0 )
	end

    if number  == 3 then
		if  xes* bss * xxs>0 
		    or sws* ((xes * bss) + (bss * xxs) + (xxs * xes)) > 1
		    or sws * (xes+bss+xxs) > 1
	    then return true
		end
	    return false
	end

	if number  == 2 then
	    if  xes * bss >0  
		    or sws * (xes + bss) > 0 
		    or sws == 2
        then return true
		end
	    return false
	end

	if number  == 1 then
	local nls = ni.player.powerraw()
	     return nls
	end
end;

local abilities = {
	["Cache"] = function()     
		Cache.enemiesn = ni.player.enemiesinrange(30)
	end,

    ["Pause"] = function()  --停止条件
	    if IsMounted()
		   or UnitInVehicle("player")
		   or UnitIsDeadOrGhost("player")
		   or UnitChannelInfo("player")
		   or UnitCastingInfo("player")
        then
			return true
		end
    	 return false
	end,
	
	["AutoAttack"] = function()  --自动攻击
	   local _, enabled = GetSetting("AutoAttack")
		if enabled then
		  if UnitCanAttack("player", "target") then return false end
		  if UnitAffectingCombat("player")
		  then
			ni.player.runtext("/startattack")  return true
		  end
		  return false
		end
	end,

	["Strangulate"] = function()   --绞袭
      local _, enabled = GetSetting("Strangulate")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				if      Ddmb(target)
				        and fwtj(4)
						and ValidUsable(spells.Strangulate.id,target)
				then
					   ni.spell.cast(spells.Strangulate.name, target)  return true
				end
			end
			return false
		end
	end,
	
	["MindFreeze"] = function()   --心灵冰冻
       local _, enabled = GetSetting("MindFreeze")
		if enabled  then
	    local enear = ni.player.enemiesinrange(5)
			for i = 1, #enear do
				local target = enear[i].guid
				if      Ddmb(target)
						and ValidUsable(spells.MindFreeze.id,target)
				then
					   ni.spell.cast(spells.MindFreeze.name, target)  return true
				end
			end
			return false
		end
	end,

	["AntiMagicShell"] = function()  --反魔法护罩反恐
	  local _, enabled = GetSetting("AntiMagicShell")
		if enabled then
		   if ni.player.debufftype("Poison|Magic|Curse|Disease")
		      and Usableplayer(spells.AntiMagicShell.id)
		   then
				ni.spell.cast(spells.AntiMagicShell.name) return true;
		   end
		   return false
		end 
	end,

	["IceboundFortitude"] = function()  --冰封之韧
	  local value, enabled = GetSetting("IceboundFortitude")
		if enabled then		
		   if ni.player.hp()< value
		      and Usableplayer(spells.IceboundFortitude.id) 
		   then
		      ni.spell.cast(spells.IceboundFortitude.name) 	return true
		   end
		   return false
		end
	end,

	["BloodPresence"] = function()  --鲜血灵气
	  local _, enabled = GetSetting("BloodPresence")
		if enabled then
		   if not ni.player.aura(48266)
		      and fwtj(4)
		      and ni.spell.available(spells.BloodPresence.id)  
		   then
		      ni.spell.cast(spells.BloodPresence.name) 	return true
		   end
		   return false
		end
	end,

	["DeathPact"] = function()  --天灾契约
	    local value, enabled = GetSetting("DeathPact")
		if enabled then
		 local creator = ni.unit.creator("playerpet");
		   if ni.player.hp()< value
		      and UnitGUID("player") == creator
		      and Usableplayer(spells.DeathPact.id) 
		   then
		      ni.spell.cast(spells.DeathPact.name) 	return true
		   end
		   return false
		end
	end,

	["DeathStrike"] = function()  --灵界打击
	  local value, enabled = GetSetting("DeathStrike")
		if enabled then
		   if fwtj(2)
		      and ni.player.hp()< value
		      and ni.unit.debuffs("target", "55095&&55078","player")
		      and ValidUsable(spells.DeathStrike.id,"target") 
		   then
		      ni.spell.cast(spells.DeathStrike.name,"target") 	return true
		   end
		   return false
		end
	end,

	["BloodTap"] = function()  --活力分流
	  local _, enabled = GetSetting("BloodTap")
		if enabled then
		   if  fwtj(5) < 2
		       and ni.player.buff(54758)    
		       and Usableplayer(spells.BloodTap.id)
		   then
				ni.spell.cast(spells.BloodTap.name) return true;
		   end
		   return false
		end 
	end,

	["UnbreakableArmor"] = function()  --铜墙铁壁
	  local _, enabled = GetSetting("UnbreakableArmor")
		if enabled then
		   if  fwtj(6)
		       and ni.player.buff(spells.BloodTap.id)
		       and Usableplayer(spells.UnbreakableArmor.id)
		   then
				ni.spell.cast(spells.UnbreakableArmor.name) return true;
		   end
		   return false
		end 
	end,

	["BloodFury"] = function()  --血性狂怒
	  local _, enabled = GetSetting("BloodFury")
		if enabled then
		   if  ni.player.buff(54758)    
		       and Usableplayer(spells.BloodFury.id)
		   then
				ni.spell.cast(spells.BloodFury.name) return true;
		   end
		   return false
		end 
	end,

	["Engineeringgloves"] = function()  --手套加速
	    local _, enabled = GetSetting("Engineeringgloves")
		if enabled then
			if UnitAffectingCombat("player")
			   and ni.player.slotcd(10) == 0 
			then
				ni.player.useinventoryitem(10) 	return true;
		    end
			return false
		end
	end,

	["EmpowerRuneWeapon"] = function()  --符文武器增效
	  local _, enabled = GetSetting("EmpowerRuneWeapon")
		if enabled then
		   if ni.rune.available() ==0
		      and fwtj(1)<60
		      and Usableplayer(spells.EmpowerRuneWeapon.id)
		   then
				ni.spell.cast(spells.EmpowerRuneWeapon.name) return true;
		   end
		   return false
		end 
	end,

	["RaiseDead"] = function()  --亡者复生
	    local _, enabled = GetSetting("RaiseDead")
		if enabled then
		   if  not ni.player.buff(51124)
		       and  not fwtj(2)
		       and Usableplayer(spells.RaiseDead.id)
		   then
				ni.spell.cast(spells.RaiseDead.name) return true;
		   end
		   return false
		end 
	end,
	
	["Pestilence"] = function()   --传染
	    local _, enabled = GetSetting("Pestilence")
		if enabled  then
		   if not  fwtj(4) or GetTime() - chuanrantm < 10  then  return false end
		   local sb = sbpd("target")
		   local enear = ni.unit.enemiesinrange("target", 14)
		   if ni.unit.debuffs("target","55095&&55078","player")  then
		       if not ValidUsable(spells.Pestilence.id, "target") then  return false end  
			   if sb - swxxpd() < 1 or (sb <= 9 and fwtj(5) == 2) or sb < 4 
			   then 
			   ni.spell.cast(spells.Pestilence.name,"target") return true 
			   end
			   for i = 1, #enear do
			       local atagger = enear[i].guid
				   if sbpd(atagger) < 3 
				      and #enear > 0
				   then 
				   ni.spell.cast(spells.Pestilence.name,"target") 
				   return true
			       end
			   end
			   return false
           else 
		       for j = 1, #enear do
			       local btagger = enear[j].guid
				   if ni.unit.debuffs(btagger,"55095&&55078","player")
				      and ValidUsable(spells.Pestilence.id, btagger)
				   then 
				   ni.spell.cast(spells.Pestilence.name,btagger) 
				   return true
			       end
			   end
               return false
           end
		end
	end,
	
	["IcyTouch"] = function()  --冰冷触摸
	  local _, enabled = GetSetting("IcyTouch")
		if enabled then
		   if ni.unit.debuff("target",55095,"player")  then return false end
		   if   fwtj(6)
                and ValidUsable(spells.IcyTouch.id, "target") 
		   then
		         ni.spell.cast(spells.IcyTouch.name, "target") 	return true
		   end
		   return false
		end
	end,

	["PlagueStrike"] = function()  --暗影打击
	  local _, enabled = GetSetting("PlagueStrike")
		if enabled then
		   if ni.unit.debuff("target",55078,"player") then return false end
		   if    fwtj(7)
                 and ValidUsable(spells.PlagueStrike.id,"target") 
		   then
		         ni.spell.cast(spells.PlagueStrike.name, "target") 	return true
		   end
		   return false
		end
	end,

	["DeathandDecay"] = function()   --枯萎凋零	
	local value, enabled = GetSetting("DeathandDecay")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local enear = #ni.unit.enemiesinrange(target, 9)
				if  enear >= value
				    and fwtj(3) 
					and ni.spell.available(spells.DeathandDecay.id)
				    and UnitAffectingCombat(target)  
				then
				    ni.spell.castat(spells.DeathandDecay.name,target)	return true
				end
			end
			return false
		end
	end,

	["HowlingBlast"] = function()   --凛风冲击
	local value, enabled = GetSetting("HowlingBlast")
		if enabled then 
		    if not ni.player.buff(51124) then return false end
		    local enear = ni.player.enemiesinrange(19) --20码内敌人
			for i = 1, #enear do
				local target = enear[i].guid
				local enea = #ni.unit.enemiesinrange(target, 9)
				if  enea > value  
				    and (ni.player.buff(59052) or fwtj(2))
				    and ValidUsable(spells.HowlingBlast.id, target)
				then 
				    ni.spell.cast(spells.HowlingBlast.name,target)	return true
				end
			end
			return false
		end
	end,

	["BloodBoil"] = function()  --血液沸腾
	  local value, enabled = GetSetting("BloodBoil")
	  local enear = #ni.player.enemiesinrange(9)
		if enabled then
		   if enear >= value 
		      and fwtj(4)
		      and Usableplayer(spells.BloodBoil.id) 
		   then
			  ni.spell.cast(spells.BloodBoil.name)  return true
		   end
		   return false
	    end
	end,

	["FrostStrike"] = function()  --冰霜打击
	  local _, enabled = GetSetting("FrostStrike")
		if enabled then
		   if not ValidUsable(spells.FrostStrike.id,"target") then return false end
		   if ni.player.buff(51124) 
		      or not fwtj(2) 
		      or fwtj(1)>=100    
		   then
		      ni.spell.cast(spells.FrostStrike.name,"target") 	return true
		   end
		   return false
		end
	end,

	["Obliterate"] = function()  --湮没
	  local _, enabled = GetSetting("Obliterate")
		if enabled then
		   if fwtj(2)
		      and ValidUsable(spells.Obliterate.id,"target") 
		   then
		      ni.spell.cast(spells.Obliterate.name,"target") 	return true
		   end
		   return false
		end
	end,

	["HowlingBlastTC"] = function()   --凛风冲击
	local _, enabled = GetSetting("FrostStrike")
		if enabled then
		local enear = ni.player.enemiesinrange(19) --20码内敌人
			for i = 1, #enear do
				local target = enear[i].guid
				if  ni.player.buff(59052) 
				    and ValidUsable(spells.HowlingBlast.id, target)
				then
				    ni.spell.cast(spells.HowlingBlast.name,target)	return true
				end
			end
			return false
		end
	end,

	["HornofWinter"] = function()  --寒冬号角
	  local _, enabled = GetSetting("HornofWinter")
		if enabled then
		   if ni.rune.available() ==0 
		      and fwtj(1)<90 
			  and Usableplayer(spells.HornofWinter.id)
		   then
				ni.spell.cast(spells.HornofWinter.name) return true;
		   end
		   return false
		end 
	end,

	["BloodStrike"] = function()  --鲜血打击
	  local _, enabled = GetSetting("BloodStrike")
		if enabled then
		   if  fwtj(4)
		       and ValidUsable(spells.BloodStrike.id,"target") 
		   then
		      ni.spell.cast(spells.BloodStrike.name,"target") 	return true
		   end
		   return false
		end
	end,

	["HornofWinterBF"] = function()  --寒冬号角
	  local _, enabled = GetSetting("HornofWinter")
		if enabled then
		   if not ni.player.buff(spells.HornofWinter.id)
		      and ni.spell.available(spells.HornofWinter.id)
		   then
				ni.spell.cast(spells.HornofWinter.name) return true;
		   end
		   return false
		end 
	end,
	
	["debug"] = function()  --调试
	local _, enabled = GetSetting("debug")
		if enabled then
		     ni.vars.debug = true
		else
             ni.vars.debug = false
		end
	end
};
ni.bootstrap.profile("Fdk", queue, abilities, OnLoad, OnUnLoad);	
